package gptma.bo.model.request;

import gptma.bo.model.BaseEntity;

import java.util.Date;

import javax.persistence.AttributeOverride;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

@Entity
@Table(name = "elementHistorique")
@AttributeOverride(name = "id", column = @Column(name = "elementHistoriqueId"))
public class RequestHistoryElement extends BaseEntity implements
		Comparable<RequestHistoryElement> {

	private static final long serialVersionUID = 1231416626371893331L;

	@Column(name = "etat")
	private String state;

	@Temporal(value = TemporalType.TIMESTAMP)
	@Column(name = "date")
	private Date date;

	@Column(name = "auteur")
	private String author;

	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "demandeClientClientId")
	private ClientRequest clientClientRequest;

	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "demandeClientAtosId")
	private ClientRequest atosClientRequest;

	/**
	 * @return the state
	 */
	public String getState() {
		return state;
	}

	/**
	 * @param state
	 *            the state to set
	 */
	public void setState(String state) {
		this.state = state;
	}

	/**
	 * @return the date
	 */
	public Date getDate() {
		return date;
	}

	/**
	 * @param date
	 *            the date to set
	 */
	public void setDate(Date date) {
		this.date = date;
	}

	/**
	 * @return the author
	 */
	public String getAuthor() {
		return author;
	}

	/**
	 * @param author
	 *            the author to set
	 */
	public void setAuthor(String author) {
		this.author = author;
	}

	@Override
	public int compareTo(RequestHistoryElement other) {
		return date.compareTo(other.date);
	}

	/**
	 * @return the clientClientRequest
	 */
	public ClientRequest getClientClientRequest() {
		return clientClientRequest;
	}

	/**
	 * @param clientClientRequest
	 *            the clientClientRequest to set
	 */
	public void setClientClientRequest(ClientRequest clientClientRequest) {
		this.clientClientRequest = clientClientRequest;
	}

	/**
	 * @return the atosClientRequest
	 */
	public ClientRequest getAtosClientRequest() {
		return atosClientRequest;
	}

	/**
	 * @param atosClientRequest
	 *            the atosClientRequest to set
	 */
	public void setAtosClientRequest(ClientRequest atosClientRequest) {
		this.atosClientRequest = atosClientRequest;
	}

}
